package com.csjbot.blackgaga.model.tcp.tts;

import android.content.Context;

import com.csjbot.blackgaga.model.tcp.base.BaseImpl;
import com.csjbot.coshandler.listener.OnSpeakListener;
import com.iflytek.cloud.SpeechError;

/**
 * Created by jingwc on 2017/9/21.
 */

public class SpeakImpl extends BaseImpl implements ISpeak {

    @Override
    public void startSpeaking(String text, OnSpeakListener listener) {
        OnSpeakListener speakListener = new OnSpeakListener() {
            @Override
            public void onSpeakBegin() {
                if(listener != null) {
                    listener.onSpeakBegin();
                }
            }

            @Override
            public void onCompleted(SpeechError speechError) {
                if(listener != null) {
                    listener.onCompleted(speechError);
                }

            }
        };
        robotManager.robot.startSpeaking(text,speakListener);
    }

    @Override
    public void stopSpeaking() {
        robotManager.robot.stopSpeaking();
    }

    @Override
    public void pauseSpeaking() {
        robotManager.robot.pauseSpeaking();
    }

    @Override
    public void resumeSpeaking() {
        robotManager.robot.resumeSpeaking();
    }

    @Override
    public boolean isSpeaking() {
        return robotManager.robot.isSpeaking();
    }

    @Override
    public void initSpeak(Context context) {
        robotManager.robot.initSpeak(context);
    }
}
